<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
	<meta http-equiv="Content-Language" content="zh-cn">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="icon" type="image/x-icon" href="${pageContext.request.contextPath}/resources/images/favicon.ico"/>
	<link href="${pageContext.request.contextPath}/resources/css/Style.css" rel="stylesheet" type="text/css" />
	<script language="javascript" src="${pageContext.request.contextPath}/resources/js/public.js"></script>
	<script type="text/javascript">
	    //添加商品
		function addProduct() {
			window.location.href = "${pageContext.request.contextPath}/ToAddProductServlet";
		}
		//删除商品
		function p_del() {   
			var msg = "您确定要删除该商品吗？";   
			if (confirm(msg)==true){   
			return true;   
			}else{   
			return false;   
			}   
		}   
	</script>
</head>
<body>
	<form id="Form1" name="Form1"
		action="${pageContext.request.contextPath}/FindProductServlet"
		method="post">
		<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
			<tbody>
				<tr>
					<td class="ta_01" align="center" bgColor="#afd1f3">
						<strong>查 询 条 件</strong>
					</td>
				</tr>
				<tr>
					<td>
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td height="22" align="center" class="ta_01">商品编号：</td>
								<td class="ta_01" >
									<input type="text" name="id" size="15" value="${requestScope.productId}" id="Form1_id" />
								</td>
								<td height="22" align="center" class="ta_01">类别：</td>
								<td class="ta_01" >
								<select name="category" id="category">
										<option value="" selected="selected">--选择商品类别--</option>
									<c:forEach items="${requestScope.allCategory}" var="ca">
                                        <option value="${ca.id}" <c:if test="${ca.id eq requestScope.categoryId}">selected</c:if>   >${ca.category}</option>
									</c:forEach>
								</select>
								</td>
							</tr>
							<tr>
								<td height="22" align="center" class="ta_01">商品名称：</td>
								<td class="ta_01" >
									<input type="text" name="name" size="15" value="${requestScope.productName}" id="Form1_userName" />
								</td>
								<td height="22" align="center" class="ta_01">价格区间(元)：</td>
								<td class="ta_01" >
									<input type="text" name="minPrice" size="10" value="${requestScope.minPrice}" />
									- 
									<input type="text" name="maxPrice" size="10" value="${requestScope.maxPrice}" />
								</td>
							</tr>
							<tr>
								<td align="right" class="ta_01" colspan="4">
									<button type="submit" id="search" name="search" value="查询" class="button_view">查询</button>
									<input type="reset" name="reset" value="重置" class="button_view" />
									<button type="button" id="add" name="add" value="添加" class="button_add" onclick="addProduct()" >添加</button>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="ta_01" align="center" bgColor="#afd1f3"><strong>商 品 列 表</strong></td>
				</tr>
				<tr>
					<td class="ta_01" align="center" bgColor="#f5fafe">
						<table cellspacing="0" cellpadding="1" rules="all"
							bordercolor="gray" border="1" id="DataGrid1"
							stylBORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH: 100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
							<tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">
								<td align="center" width="10%">商品编号</td>
								<td align="center" width="18%">商品名称</td>
								<td align="center" width="9%">商品价格</td>
								<td align="center" width="9%">商品数量</td>
								<td width="8%" align="center">商品类别</td>
                                <td width="8%" align="center">状态</td>
								<td width="8%" align="center">编辑</td>
								<td width="8%" align="center">删除</td>
							</tr>
                            <!--  循环输出所有商品 -->
							<c:forEach items="${requestScope.allProduct}" var="product">
								<tr onmouseover="this.style.backgroundColor = 'white'"
									onmouseout="this.style.backgroundColor = '#F5FAFE';">
									<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="200">${product.id }</td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="18%">${product.name }</td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${product.price }</td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="8%">${product.pnum }</td>
									<td style="CURSOR: hand; HEIGHT: 22px" align="center">${product.category}</td>
									<td align="center" style="HEIGHT: 22px" width="8%">
										<c:if test="${product.status eq '0'}">有效</c:if>
										<c:if test="${product.status eq '1'}">无效</c:if>
									</td>
									<td align="center" style="height: 22px" width="7%">
										<a href="${pageContext.request.contextPath}/ToEditorProductServlet?id=${product.id}&type=admin">
											<img src="${pageContext.request.contextPath}/resources/images/i_edit.gif" border="0" style="cursor: hand">
										</a>
									</td>
									<td align="center" style="height: 22px" width="7%">
										<a href="${pageContext.request.contextPath}/DeleteProductServlet?id=${product.id}" onclick="javascript:return p_del()">
											<img src="${pageContext.request.contextPath}/resources/images/i_del.gif"
												 width="16" height="16" border="0" style="cursor: hand">
										</a>
									</td>
								</tr>
							</c:forEach>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</body>
</html>